<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/token.jsp"%>
<%@ include file="/common/user.jsp"%>
<%!
	// 通知详情
	String show(Input input, Integer uid) {
		Message msg = new Message(0);
		Integer hospital = input.getInt("hospital", 20); 
		Integer id = input.getInt("id", 20); 
		String hql = "select new map(n.id as id, n.title as title, n.content as content, concat(FROM_UNIXTIME(n.cTime/1000,'%Y-%m-%d %H:%i:%s'), '')  as create_time, nc.isConfirmed as is_confirmed, case when n.imgs is null then '[]' else imgs end as imgs, case when n.voices is null then '[]' else voices end as voices,n.sender as sender) from  Notification as n, NotificationConfirm as nc where nc.nid=n.id and nc.uid=" + uid + " and n.id=" + id + " and n.hospital=" + hospital + " and n.status=" + STATUS_ENABLE + "  and nc.status= " + STATUS_ENABLE ;
		List<Map> notifictionList = QBuilder.db("basedb").queryHql(hql);
		if (isEmpty(notifictionList)) {
			msg.setErrcodeAndErrmsg(30041, "没有更多通知");
			return msg.toJson();
		}
		List<Integer> list = new ArrayList<Integer>();
		for (Map map:notifictionList) {
			list.add(Tools.getInt(map.get("sender")+""));
		}
		Map<Integer, User> userMap = usersByUids(list);
		for (Map map:notifictionList) {
			User user = userMap.get(Tools.getInt(map.get("sender")+""));
			if (user != null) {
				map.put("sender_name", user.getName());
				map.put("sender_avatar", user.getAvatar());
				map.put("sender_title", user.getTitle());
			}
		}
		msg.put("data", notifictionList.get(0));
		return msg.toJson();
	}
%>
<%
	Tools.encryptPrint(out, show(input, token.getUid()));
%>
